package com.bzkj.web.controller.ncc;

import com.bzkj.basicinfo.service.ncc.NccBasicStoStockService;
import com.bzkj.common.core.controller.BaseController;
import com.bzkj.common.core.domain.AjaxResult;
import com.bzkj.inventory.service.NccloudSaleoutSignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/ncc")
public class NccloudSaleoutSignController extends BaseController {
    @Autowired
    private NccloudSaleoutSignService saleoutSignService;

    /**
     * 销售出库签字
     */
    @GetMapping("/nccloudSaleoutSign")
    @PreAuthorize("@ss.hasPermi('ncc:NccloudSaleoutSign:Job')")
    public AjaxResult ncccloudSaleoutSign(List<String> cgeneralhid) {
        AjaxResult sign = saleoutSignService.sign(cgeneralhid);
        Boolean tag = (Boolean) sign.get("tag");
        String msg = (String) sign.get("msg");

        if (!tag && cgeneralhid.size() > 1) {
            return AjaxResult.error("批量签字失败，请单独操作");
        } else if (tag && cgeneralhid.size() > 1) {
            return AjaxResult.success("批量签字成功");
        }else if (!tag && cgeneralhid.size() == 1){
            return AjaxResult.error(msg);
        }else{
            return AjaxResult.success(msg);
        }
    }
}
